package com.yonyou.crm.bpub.topbar.service;

import java.util.*;

import org.springframework.stereotype.Service;

import com.yonyou.crm.base.doc.entity.DocEnum;
import com.yonyou.crm.bpub.topbar.entity.*;
import com.yonyou.crm.common.filter.entity.AppFilterTypeConstant;
import com.yonyou.crm.common.search.entity.AppSearchPlanEnum;
import com.yonyou.crm.common.sort.entity.AppSortPlanEnum;

@Service
public class CustomerTopbar extends BaseTopbar {
	
	@Override
	public PlanVO getPresetOptions(){
		PlanVO presetOption = new PlanVO();
		presetOption.setTitle("预置选择");
		
		List<DataItemVO> data = new ArrayList<>();
		DataItemVO item;
		
		item = new DataItemVO(String.valueOf(AppSearchPlanEnum.ALL.getValue()), AppSearchPlanEnum.ALL.getName());
		data.add(item);
		
		item = new DataItemVO(String.valueOf(AppSearchPlanEnum.OWNER.getValue()), AppSearchPlanEnum.OWNER.getName());
		data.add(item);
		
		item = new DataItemVO(String.valueOf(AppSearchPlanEnum.REL.getValue()), AppSearchPlanEnum.REL.getName());
		data.add(item);
		
		item = new DataItemVO(String.valueOf(AppSearchPlanEnum.FOLLOW.getValue()), AppSearchPlanEnum.FOLLOW.getName());
		data.add(item);
		
		item = new DataItemVO(String.valueOf(AppSearchPlanEnum.VIEW.getValue()), AppSearchPlanEnum.VIEW.getName());
		data.add(item);
		
		item = new DataItemVO(String.valueOf(AppSearchPlanEnum.WEEKFOLLOWUP.getValue()), AppSearchPlanEnum.WEEKFOLLOWUP.getName());
		data.add(item);
		
		presetOption.setData(data);
		
		return presetOption;
	};
	
	@Override
	public String getSearchPlaceholder(){
		String searchText = "客户名称/详细地址";
		return searchText;
	}
	
	@Override
	public PlanVO getSortData(){
		PlanVO sortData = new PlanVO();
		sortData.setTitle("排序");
		
		List<DataItemVO> data = new ArrayList<>();
		DataItemVO item;
		
		item = new DataItemVO(String.valueOf(AppSortPlanEnum.NAME.getValue()), "客户" + AppSortPlanEnum.NAME.getName());
		data.add(item);
		
		item = new DataItemVO(String.valueOf(AppSortPlanEnum.BUYPOTENTIAL.getValue()), AppSortPlanEnum.BUYPOTENTIAL.getName());
		data.add(item);
		
		item = new DataItemVO(String.valueOf(AppSortPlanEnum.CREATETIME.getValue()), AppSortPlanEnum.CREATETIME.getName());
		data.add(item);
		
		item = new DataItemVO(String.valueOf(AppSortPlanEnum.FOLLOWUPTIME.getValue()), AppSortPlanEnum.FOLLOWUPTIME.getName());
		data.add(item);

		sortData.setData(data);
		return sortData;
	};
	
	@Override
	public List<SelectDataVO> getSelectData(){
		List<SelectDataVO> selectData = new ArrayList<SelectDataVO>();
		SelectDataVO select;
		List<DataItemVO> data;
		
		select = new SelectDataVO();
		select.setKey("types");
		select.setType(AppFilterTypeConstant.Multiple);
		select.setTitle("客户类型");
//		data = getEnumList("cum_type");
		Integer cumTypeId = DocEnum.CUMTYPE.getValue();
		data = getEnumListFromDoc(cumTypeId.toString(), "客户类型");
		select.setData(data);
		selectData.add(select);
		
		select = new SelectDataVO();
		select.setKey("levels");
		select.setType(AppFilterTypeConstant.Multiple);
		select.setTitle("客户等级");
//		data = getEnumList("cum_level");
		Integer cumLevelId = DocEnum.CUMLEVEL.getValue();
		data = getEnumListFromDoc(cumLevelId.toString(), "客户等级");
		select.setData(data);
		selectData.add(select);
		
		select = new SelectDataVO();
		select.setKey("states");
		select.setType(AppFilterTypeConstant.Multiple);
		select.setTitle("客户状态");
//		data = getEnumList("cum_state");
		Integer cumStateId = DocEnum.CUMSTATUS.getValue();
		data = getEnumListFromDoc(cumStateId.toString(), "客户状态");
		select.setData(data);
		selectData.add(select);
		
		select = new SelectDataVO();
		select.setKey("industry");
		select.setType(AppFilterTypeConstant.Refer);
		select.setTitle("行业");
		select.setReferto("Industry");
		selectData.add(select);
		
		select = new SelectDataVO();
		select.setKey("cannelTypes");
		select.setType(AppFilterTypeConstant.Multiple);
		select.setTitle("客户渠道类型");
		Integer chnlTypeId = DocEnum.CHNLTYPE.getValue();
		data = getEnumListFromDoc(chnlTypeId.toString(), "客户渠道类型");
		select.setData(data);
		selectData.add(select);
		
		select = new SelectDataVO();
		select.setKey("province_city_district");
		select.setType(AppFilterTypeConstant.PCDPicker);
		select.setTitle("省/市/区");
		selectData.add(select);

		return selectData;
	}

}
